package SmartHome.devices;

import SmartHome.observers.Observer;
import SmartHome.states.DeviceState;
import SmartHome.strategys.DeviceStrategy;

//观察者模式，模板模式，状态模式，策略模式
public abstract class SmartDevice implements Observer {
    protected DeviceState state;
    protected DeviceStrategy strategy;

    public SmartDevice() {
    }

    public SmartDevice(DeviceState state, DeviceStrategy strategy) {
        this.state = state;
        this.strategy = strategy;
    }

    public abstract void powerOn();
    public abstract void turnOn();
    public abstract void turnOff();

    public final void start(){
        System.out.println("设备启动中...");
        powerOn();
        turnOn();
    }

    public void setState(DeviceState state) {
        this.state = state;
        System.out.println("设备状态切换为: " + state.getClass().getSimpleName());
    }

    public void setStrategy(DeviceStrategy strategy) {
        this.strategy = strategy;
        System.out.println("设备策略切换为: " + strategy.getClass().getSimpleName());
    }


}
